<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title></title>
</head>

<body>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>元件 - 在线计算器_科学计算器_电阻计算器_在线工具- 21IC中国电子网</title>
    <link href="http://www.21ic.com/tools/css/tools.css" rel="stylesheet" type="text/css">
</head>

<body>

<div class="mobile_main">
    <script>
					function perRound(num, precision) {

						var precision = 3;
						precision = parseInt(precision);
						var result1 = num * Math.pow(10, precision);

						var result2 = Math.round(result1);

						var result3 = result2 / Math.pow(10, precision);

						return zerosPad(result3, precision);

					}

					function zerosPad(rndVal, decPlaces) {

						var valStrg = rndVal.toString(); // Convert the number to a string

						var decLoc = valStrg.indexOf("."); // Locate the decimal point

						// check for a decimal

						if(decLoc == -1) {

							decPartLen = 0; // If no decimal, then all decimal places will be padded with 0s

							// If decPlaces is greater than zero, add a decimal point

							valStrg += decPlaces > 0 ? "." : "";

						} else {

							decPartLen = valStrg.length - decLoc - 1; // If there is a decimal already, only the needed decimal places will be padded with 0s

						}

						var totalPad = decPlaces - decPartLen; // Calculate the number of decimal places that need to be padded with 0s

						if(totalPad > 0) {

							// Pad the string with 0s

							for(var cntrVal = 1; cntrVal <= totalPad; cntrVal++)

								valStrg += "0";

						}

						return valStrg;

					}

					// send the value in as "num" in a variable

					// clears field of default value

					function clear_field(field) {

						if(field.value == field.defaultValue) {

							field.value = ''

						}

					}

					function calcTimer(obj) {

						with(Math) {

							cap1 = eval(obj.farads.value);

							res1 = eval(obj.ohms1.value);

							res2 = eval(obj.ohms2.value);

							temp1 = .693 * cap1 * (res1 + res2)

							temp2 = .693 * cap1 * res2

							temp3 = 1 / (.693 * cap1 * (res1 + (2 * res2)))

							temp4 = (temp1 / (temp1 + temp2)) * 100

							obj.hs.value = temp1;

							obj.ls.value = temp2;

							obj.hertz.value = temp3;

							obj.dcp.value = temp4;

							obj.rhs.value = perRound(temp1);

							obj.rls.value = perRound(temp2);

							obj.rhertz.value = perRound(temp3);

							obj.rdcp.value = perRound(temp4);
						}
					}
					//-->


    </script>
    <form name="Timer555">
        <table id="table6" width="100%" cellpadding="1" border="1" align="center">
            <tbody>
            <tr bgcolor="#b6d4d2">
                <td colspan="2" align="center"><b>555 方波计算器</b></td>
            </tr>
            <tr bgcolor="#b6d4d2">
                <td colspan="2" align="center">参数输入</td>
            </tr>
            <tr>
                <td><input size="18" onfocus="clear_field(this)" name="farads" value="0"
                           type="text"></td>
                <td>C(F)</td>
            </tr>
            <tr>
                <td><input size="18" onfocus="clear_field(this)" name="ohms1" value="0" type="text">
                </td>
                <td>R1(ohm)</td>
            </tr>
            <tr>
                <td><input size="18" onfocus="clear_field(this)" name="ohms2" value="0" type="text">
                </td>
                <td>R2(ohm)</td>
            </tr>
            <tr>
                <td colspan="2" align="center"><input onclick="calcTimer(this.form)" value="开始计算"
                                                      type="button">&nbsp;&nbsp;&nbsp; <input
                        value="重 置" type="reset"></td>
            </tr>
            <tr bgcolor="#b6d4d2">
                <td colspan="2" align="center">实示计算结果</td>
            </tr>
            <tr>
                <td><input readonly="readonly" size="18" name="dcp" value="0" type="text"></td>
                <td>占空比</td>
            </tr>
            <tr>
                <td><input readonly="readonly" size="18" name="hertz" value="0" type="text"></td>
                <td>频率(Hz)</td>
            </tr>
            <tr>
                <td><input readonly="readonly" size="18" name="ls" value="0" type="text"></td>
                <td>TL(s)</td>
            </tr>
            <tr>
                <td><input readonly="readonly" size="18" name="hs" value="0" type="text"></td>
                <td>TH(s)</td>
            </tr>
            <tr bgcolor="#b6d4d2">
                <td colspan="2" align="center">保留有效位数后结果</td>
            </tr>
            <tr>
                <td><input readonly="readonly" size="18" name="rdcp" value="0" type="text"></td>
                <td>占空比</td>
            </tr>
            <tr>
                <td><input readonly="readonly" size="18" name="rhertz" value="0" type="text"></td>
                <td>频率( Hz)</td>
            </tr>
            <tr>
                <td><input readonly="readonly" size="18" name="rls" value="0" type="text"></td>
                <td>TL(seconds)</td>
            </tr>
            <tr>
                <td><input readonly="readonly" size="18" name="rhs" value="0" type="text"></td>
                <td>TH(seconds)</td>
            </tr>
            </tbody>
        </table>
    </form>
    <div style="height:10px;"></div>
    <div class="mob_det">输入参数:R1 (ohm); R2(ohm); C(F)
        <p>输出参数:占空比(%), 高电平时间(s),低电平时间(s), 频率(Hz)</p>
        <p>计算公式:<br> TH (高电平时间s) = 0.693 * (R1 + R2) * C<br> TL (低电平时间s) = 0.693 * R2 * C<br>
            Frequency(输出频率) = 1.44 / ((R1 + R2 + R2) * C)<br> DCP(占空比%) = (T(h) / (T(h) + T(l))) *
            100<br> &nbsp;
        </p>
        <img alt="555timer" src="img/555timer.png" style="width:100%;">
    </div>

</div>

</body>

</html>
</body>

</html>